SUBROUTINE GETPARAM
     * Validate contents of a simple form.
     * If the contents are invalid, return the invalid data to the
     * original form.
     * Otherwise, display the data entered for checking.

     * Include the RealWeb definitions
     INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

     EQU AM TO CHAR(254)

     * Get the form data.
     NAME = ""
     CALL RW_GET_PARAM("NAME", NAME)

     VALID = 0
     * Check that we have a name and that it doesn't contain any numeric characters.
     FOR I = 1 TO LEN(NAME)
        VALID = 1
        IF NAME[I, 1] >= "0" AND NAME[I, 1] <= "9" THEN VALID = 0
        UNTIL VALID = 0
     NEXT I

     * If valid...
     IF VALID = 1 THEN
        * Display the data entered for checking.
        CALL RW_START_HTML_PAGE("Name and Age check", "", "", "", "")

        CALL RW_START_PARA("", "")
        CALL RW_PUT("Name, " : NAME)
        CALL RW_END_PARA

        CALL RW_END_PAGE

     * Otherwise...
     END ELSE
        * Set a parameter to show which field contains invalid data.
        CALL RW_SET_PARAM("ERRORS", "NAME")

        * Redisplay the original form.
        * The invalid parameter is still in the buffer and will
        * therefore be available for display.
        CALL GETPARAMTEST
     END
RETURN

Go to top button